package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Println("usage: go run fetch <url>")
		os.Exit(-1)
	}

	url := os.Args[1]
	if !strings.HasPrefix(url, "http://") {
		url = "http://" + url
	}
	res, err := http.Get(url)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v", err)
	}

	_, err = io.Copy(os.Stdout, res.Body)
	res.Body.Close()

	if err != nil {
		fmt.Fprintf(os.Stderr, "%v", err)
	}
}
